﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Job.Entity;
using Job.Logic.BaseContent;
using Job.Web.Framework;

namespace Job.Web.userControls.Public
{
    public partial class Header : BaseCtrl
    {
        int subjectId = myR["subjectid"].IntValue;

        int contentId = myR["contentid"].IntValue;

        int categoryId = myR["categoryid"].IntValue;

        public int GetCategoryId()
        {
            if (categoryId > 0) return categoryId;
            if (subjectId > 0)
            {
                BaseInfo info = WebCommon.GetSubjectInfo(subjectId);
                return info.CatagoryId;
            }

            if (contentId > 0)
            {
                JobBaseContent content = new BaseContentLogic().GetContentByContentId(contentId);
                BaseInfo info = WebCommon.GetSubjectInfo(content.SubjectId.Value);
                return info.CatagoryId;
            }
            return 0;

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            //    WebCommon.SetDropDownFromDict(ddlSalaryItem, "",
            //        Constants.GetDictionaryCode(Constants.DictionaryType.SALARY_LEVEL), true);
            //}

            MySession session = new MySession();
            if (session.GetPersonalFromSession() != null)
            {
                if (hlPerson1 != null)
                    hlPerson1.NavigateUrl = WebCommon.GetApplicationPath(Request)
                         + "Person/PersonManager.aspx?categoryid=1&ctrlid=2";
                if (hlPerson2 != null)
                    hlPerson2.NavigateUrl = WebCommon.GetApplicationPath(Request)
                         + "Person/PersonManager.aspx?categoryid=1&ctrlid=2";
            }
            else
            {
                if (hlPerson1 != null)
                    hlPerson1.NavigateUrl = WebCommon.GetApplicationPath(Request)
                         + "Person/PersonLogin.aspx?categoryid=1";
                if (hlPerson2 != null)
                    hlPerson2.NavigateUrl = WebCommon.GetApplicationPath(Request)
                         + "Person/PersonLogin.aspx?categoryid=1";
            }

            if (session.GetCompanyFromSession() != null)
            {
                if (hlCompany1 != null)
                    hlCompany1.NavigateUrl = WebCommon.GetApplicationPath(Request)
                        + "Company/CompanyManager.aspx?categoryid=2&subjectid=2";
                if (hlCompany2 != null)
                    hlCompany2.NavigateUrl = WebCommon.GetApplicationPath(Request)
                        + "Company/CompanyManager.aspx?categoryid=2&subjectid=2";

            }
            else
            {
                if (hlCompany1 != null)
                    hlCompany1.NavigateUrl = WebCommon.GetApplicationPath(Request)
                        + "Company/CompanyLogin.aspx?categoryid=2";
                if (hlCompany2 != null)
                    hlCompany2.NavigateUrl = WebCommon.GetApplicationPath(Request)
                        + "Company/CompanyLogin.aspx?categoryid=2";
            }

        }

        //protected void btSearch_Click(object sender, EventArgs e)
        //{            
        //    string name = tbPositionName.Text.Trim();
        //    string key = tbKey.Text.Trim();
        //    string salary = ddlSalaryItem.SelectedValue;

        //    String url = WebCommon.GetApplicationPath(Request)
        //            + "Item.aspx?categoryid=" + ((int)Constants.CategoryType.Hunter).ToString()
        //            + "&subjectid=" + ((int)Constants.SubjectType.HunterPositionList).ToString()
        //            + "&name=" + name + "&key=" + key + "&salary=" + salary;
        //    Response.Redirect(url);
        //}

    }
}